﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using CommonExtensions.IListExtensions;

namespace CommonExtensions.Tests
{
    public class IListExtensionsTests
    {
        [Fact]
        public void AddRangeShouldThrowIfNull()
        {
            IList<object> list = null;
            Assert.Throws<ArgumentNullException>(() => list.AddRange(new object[] {"1"}));
        }

        [Fact]
        public void AddRangeShouldThrowIfCollectionIsNull()
        {
            Assert.Throws<ArgumentNullException>(() => new List<object>().AddRange(null));
        }

        [Fact]
        public void AddRangeShouldAddAllElementsFromCollectionToTheList()
        {
            IList<int> list = new List<int>();
            var toAdd = new List<int> {1, 2, 3};
            list.AddRange(toAdd);

            foreach (int i in toAdd)
            {
                Assert.Contains(i, list);
            }
        }
    }
}
